#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>

using namespace std;

int alternatingSubarray(vector<int>& nums) {
    int res = -1;
    int n = nums.size();
    for (int idx = 0; idx < n; idx++)
        for (int i = idx + 1; i < n; i++)
        {
            int len = i - idx + 1;
            if (nums[i] - nums[idx] == (len - 1) % 2)
                res = max(res, len);
            else    break;
        }
    return res;
}